//
//  GenderPopView.m
//  TQY
//
//  Created by 甘世清 on 2024/10/7.
//

#import "GenderPopView.h"

@implementation GenderPopView

- (void)SQ_UIViewForSelfView{
    [self addSubview:self.nanBtn];
    [self addSubview:self.nvBtn];
    [self.nanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(140);
        make.centerX.equalTo(self).offset(-SCREEN_WIDETH/4);
        make.centerY.equalTo(self);
    }];
   
    [self.nvBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(140);
        make.centerX.equalTo(self).offset(SCREEN_WIDETH/4);
        make.centerY.equalTo(self);
    }];
    WS(weakSelf);
    [self.nanBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [[Manager SQ_getCurrentViewController].view endEditing:YES];
        if ([UserModel share].gender > 0) {
            [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"性别设置后不可修改")];
            return;
        }
        [weakSelf SQ_setBtnClick: button];
    }];
    [self.nvBtn setTouchBlock:^(SQCustomButton * _Nonnull button) {
        [[Manager SQ_getCurrentViewController].view endEditing:YES];
        if ([UserModel share].gender > 0) {
            [YJProgressHUD showMsgWithoutView:SQNSLocalString(@"性别设置后不可修改")];
            return;
        }
        [weakSelf SQ_setBtnClick: button];
    }];
    if ([UserModel share].gender == 1) {
        [weakSelf SQ_setBtnClick: self.nanBtn];
    } else if ([UserModel share].gender == 2) {
        [weakSelf SQ_setBtnClick: self.nvBtn];
    }
}
-(void)SQ_setBtnClick:(SQCustomButton*)button{
  
    if (button == self.nanBtn) {
        self.nanBtn.image = SQGetImage(@"男生 亮");
        self.nvBtn.image = SQGetImage(@"女生 灰");
        self.nanBtn.textColor = SQColor(@"#41C4FF");
        self.nvBtn.textColor = SQColor(@"#AAAAAA");
        self.gender = @"1";
    } else {
        self.nanBtn.image = SQGetImage(@"男生 灰");
        self.nvBtn.image = SQGetImage(@"女生 亮");
        self.nvBtn.textColor = SQColor(@"#FF41B1");
        self.nanBtn.textColor = SQColor(@"#AAAAAA");
        self.gender = @"2";
    }
  
    
}
- (SQCustomButton *)nanBtn{
    if (!_nanBtn) {
        _nanBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(130, 130) midmargin:-10];
        _nanBtn.text = SQNSLocalString(@"男生");
        _nanBtn.font = FONT_MEDIUM(16);
        _nanBtn.textColor = SQColor(@"#AAAAAA");
        _nanBtn.image = SQGetImage(@"男生 灰");
        
    }
    return _nanBtn;
}
- (SQCustomButton *)nvBtn{
    if (!_nvBtn) {
        _nvBtn = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(130, 130) midmargin:-10];
        _nvBtn.text = SQNSLocalString(@"女生");
        _nvBtn.font = FONT_MEDIUM(16);
        _nvBtn.textColor = SQColor(@"#AAAAAA");
        _nvBtn.image = SQGetImage(@"女生 灰");
    }
    return _nvBtn;
}

@end
